@extends('layouts.console_header')

@section('title', '代理商待提现')

@section('resources')
    @parent
    <style>
        .prompt_double{width: 500px;position: fixed;top: 200px;left: 50%;margin-left: -250px;background-color: #fff;z-index: 1001;box-shadow: 0px 0px 5px 5px rgba(128,128,128,0.5);}
        .prompt_double .title{font-size: 24px;color: #343434;margin-top: 30px;text-align: center;}
        .prompt_double .title input{width: 250px;height: 20px;border: 1px solid #000;padding: 5px;margin-left: 15px;}
        .prompt_double .close_pic{width: 30px;height: 30px;position: absolute;top: 10px;right: 10px;}
        .prompt_double .button{margin-top: 30px;font-size: 24px;}
        .prompt_double .button span{width: 100px;height: 40px;text-align: center;line-height: 40px;border-radius: 5px;cursor: pointer;}
        .prompt_double .button .cancel{margin: 10px 0 30px 20px;background-color: #eee;}
        .prompt_double .button .sure{margin: 10px 20px 30px 0;}
        .prompt_success{width: 100px;position: fixed;top: 250px;left: 50%;margin-left: -60px;background: rgba(0,0,0,0.5);padding: 10px;z-index: 1002;text-align: center;color: #fff;display: none;}
    </style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>财务中心></span>
		    <span class="co_violet">代理商待提现</span>
		</p>
		<a href="/console/finance/agent/shopwaitwithdrawal/export"><p class="fr tc back_btn">导出</p></a>
	</div>
	<table class="finance_top_list">
		<tr>
			<th>待提现笔数</th>
			<th>待提现金额(元)</th>
		</tr>
		<tr>
			<td>{{$count}}</td>
			<td>{{$sum}}</td>
		</tr>
	</table>
	<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                {{--<th>代理商编号</th>--}}
                <th>结算月份</th>
                <th>代理城市</th>
                <th>持卡人</th>
                <th>银行卡号</th>
                <th>银行名称</th>
                <th>开户行所在地</th>
                <th>开户行名称</th>
                <th>提现金额(元)</th>
                <th>操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                {{--<th>代理商编号</th>--}}
                <th>结算月份</th>
                <th>代理城市</th>
                <th>持卡人</th>
                <th>银行卡号</th>
                <th>银行名称</th>
                <th>开户行所在地</th>
                <th>开户行名称</th>
                <th>提现金额(元)</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody>
            @foreach($lists as $list)
            <tr>
            @if(!isset($i))
                <td>{{$i=1}}</td>
            @else
                <td>{{++$i}}</td>
            @endif
                <td>{{$list['accountmonth']}}</td>
{{--                <td>{{$list['cityid']}}</td>--}}
                <td>{{$list['cityname']}}</td>
                <td>{{$list['cardholder']}}</td>
                <td>{{$list['bankcard']}}</td>
                <td>{{$list['bankname']}}</td>
                <td>{{$list['bankprovince']}} - {{$list['bankcity']}}</td>
                <td>{{$list['opencardbank']}}</td>
                <td>{{$list['accountamount']}}</td>
                <td><a href="#" onclick="remit('{{$list['withdrawalid']}}', '{{$list['cityid']}}')">打款</a></td>
            </tr>
            @endforeach
        </tbody>
    </table>
    <p class="prompt_success"></p>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
    
    //打款
    var promptDouble = $('<div class="prompt_double">'+
                            '<img class="fr close_pic" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">'+
                            '<p class="title">确定要打款？</p>'+
                            '<p class="title" style="font-size: 18px;">打款密码:<input id="paymoney_password" type="password" name="" value=""></p>'+
                            '<p class="button oh">'+
                                '<span class="fl cancel">取消</span>'+
                                '<span class="fr sure">确定</span>'+
                            '</p>'+
                        '</div>');
    function remit(withdrawalid, agentcityid) {
        withdrawalid = withdrawalid;
        $(".public_prompt_mark").show();
        $(".public_prompt_mark").height($(window).height());
        $('body').append(promptDouble);
        var cityid = "{{$cityid}}";
        $(".prompt_double .sure").click(function(){
            var paymoney_password = $("#paymoney_password").val();
            if(paymoney_password == ""){
                alert("请输入密码");return false;
            }else {
                $.ajax({
                    "url":"/console/finance/agent/shopwaitwithdrawal/remit",
                    "dataType":"json",
                    "data":{
                        "withdrawalid":withdrawalid,
                        "agentcityid":agentcityid,
                        "password":paymoney_password,
                        "cityid":cityid
                    },
                    "type":"post",
                    "async":"true"
                }).success(function(data){
                    $(".public_prompt_mark").show();
                    $(".prompt_success").show();
                    $(".prompt_success").html(data.message);
                    setTimeout(function(){
                        window.location.reload();
                    },2000)
                }).error(function(data){
                    $(".prompt_success").show();
                    $(".prompt_success").html(data.message);
                });
            }
        });
        $(".prompt_double .cancel").click(function(){
            $(".public_prompt_mark").hide();
            $(".prompt_double").remove();
        });
        $(".prompt_double .close_pic").click(function(){
            $(".public_prompt_mark").hide();
            $(".prompt_double").remove();
        });
    }
//    //打款
//    function remit(withdrawalid) {
//        var is_confirm = confirm('确定打款？');
//        if(is_confirm) {
//            $.ajax({
//                "url":"",
//                "dataType":"json",
//                "data":{
//                   'cityid':
//                    },
//                "type":"post",
//                "async":"true"
//            }).success(function(data){
//                window.location.reload();
//            }).error(function(data){
//
//            });
//        }
//    }
    </script>
@endsection